Shader "Custom/Diffuse_Phong" {
	Properties {
		_Color("color",color) = (1,1,1,1)
	}
	SubShader {
		Tags { "RenderType"="Opaque" "LightMode"="ForwardBase"}
		LOD 200
		Pass{
		CGPROGRAM
		#include "UnityCG.cginc"
		#pragma vertex vert
		#pragma fragment frag
		
		float4 _Color;
		float4 _LightColor0;
		
		struct v2f{
			float4 pos:POSITION;
			float3 normal:TEXCOORD0;
			float3 worldPos:TEXCOORD1;
		};
		
		v2f vert(appdata_base i){
			v2f v;
			v.pos = mul(UNITY_MATRIX_MVP,i.vertex);
			
			v.normal = normalize(mul(float4(i.normal,0),_World2Object).xyz);
			v.worldPos = mul(_Object2World,i.vertex);
			
			return v;
		}
		
		float4 frag(v2f i):COLOR{
			float4 color = float4(0);
			float3 lightDir = normalize(_WorldSpaceLightPos0.xyz);
			float diff = max(0,dot(i.normal,lightDir));
			
			color = _Color * _LightColor0 * diff;
			return color;
		}
		
		ENDCG
		}
	} 
	FallBack "Diffuse"
}
